package Projekt;

import java.awt.Font;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class OrganizerSettingsData {
	
	public class Settings {
		public Font font;
		public int offset;
		public Settings(Font font, int offset)
		{
			this.font = font;
			this.offset = offset;
		}
	}
	
	public static void saveSettingsToFile(File file, Settings set) throws IOException
	{
		try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file))) {
			out.writeObject(set.font);
			out.writeInt(set.offset);
		} 
	}
	
	public static Settings loadSettingsFromFile(File file) throws FileNotFoundException, IOException, ClassNotFoundException
	{
		try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) {
			Font font = (Font) in.readObject();
			int offset = in.readInt();
			return new OrganizerSettingsData().new Settings(font, offset);
		} 
	}
}
